﻿using Silverlight.Training.Client.Common.ServiceReference.EventArgs;
using Silverlight.Training.Client.Common.ServiceReference.Contracts;

namespace SilverLight.Training.Models
{
    public class JobTitleDetailsModel : ModelBase
    {
        public event System.EventHandler<CollectionFeedbackCompletedEventArgs<JobTitle>> GetJobTitleCollectionCompleted;
        public event System.EventHandler<SingleFeedbackCompletedEventArgs<JobTitle>> GetSingleJobTitleCompleted;

        public JobTitleDetailsModel() : base()
        {
            client.GetJobTitleCollectionCompleted += client_GetJobTitleCollectionCompleted;
            client.GetSingleJobTitleCompleted += client_GetSingleJobTitleCompleted;
        }

        public void GetJobTitleCollectionAsync()
        {
            client.GetJobTitleCollectionAsync();
        }

        public void GetSingleJobTitleAsync(int JobTitleID)
        {
            client.GetSingleJobTitleAsync(JobTitleID);
        }

        void client_GetSingleJobTitleCompleted(object sender, SingleFeedbackCompletedEventArgs<JobTitle> e)
        {
            if (GetSingleJobTitleCompleted != null)
            {
                GetSingleJobTitleCompleted(sender, e);
            }
        }

        void client_GetJobTitleCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<JobTitle> e)
        {
            if (GetJobTitleCollectionCompleted != null)
            {
                GetJobTitleCollectionCompleted(sender, e);
            }
        }
    }
}
